package com.ruoyi.web.controller.pack;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pack.domain.PackContainerOperationLog;
import com.ruoyi.pack.service.IPackContainerOperationLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 器具操作记录Controller
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@RestController
@RequestMapping("/pack/container/operation/log")
public class PackContainerOperationLogController extends BaseController
{
    @Autowired
    private IPackContainerOperationLogService packContainerOperationLogService;

    /**
     * 查询器具操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(PackContainerOperationLog packContainerOperationLog)
    {
        startPage();
        List<PackContainerOperationLog> list = packContainerOperationLogService.selectPackContainerOperationLogList(packContainerOperationLog);
        return getDataTable(list);
    }

    /**
     * 查询器具操作记录列表（带搜索条件）
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:list')")
    @PostMapping("/search")
    public TableDataInfo search(@RequestBody Map<String, Object> params)
    {
        startPage();
        List<PackContainerOperationLog> list = packContainerOperationLogService.selectPackContainerOperationLogListWithParams(params);
        return getDataTable(list);
    }

    /**
     * 导出器具操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:export')")
    @Log(title = "器具操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody Map<String, Object> params)
    {
        List<PackContainerOperationLog> list = packContainerOperationLogService.selectPackContainerOperationLogListWithParams(params);
        ExcelUtil<PackContainerOperationLog> util = new ExcelUtil<PackContainerOperationLog>(PackContainerOperationLog.class);
        util.exportExcel(response, list, "器具操作记录数据");
    }

    /**
     * 获取器具操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(packContainerOperationLogService.selectPackContainerOperationLogByLogId(logId));
    }

    /**
     * 新增器具操作记录
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:add')")
    @Log(title = "器具操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PackContainerOperationLog packContainerOperationLog)
    {
        return toAjax(packContainerOperationLogService.insertPackContainerOperationLog(packContainerOperationLog));
    }

    /**
     * 修改器具操作记录
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:edit')")
    @Log(title = "器具操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PackContainerOperationLog packContainerOperationLog)
    {
        return toAjax(packContainerOperationLogService.updatePackContainerOperationLog(packContainerOperationLog));
    }

    /**
     * 删除器具操作记录
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:remove')")
    @Log(title = "器具操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(packContainerOperationLogService.deletePackContainerOperationLogByLogIds(logIds));
    }

    /**
     * 获取筛选条件选项
     */
    @PreAuthorize("@ss.hasPermi('pack:container:operation:log:list')")
    @GetMapping("/filter/options")
    public AjaxResult getFilterOptions()
    {
        return success(packContainerOperationLogService.getFilterOptions());
    }
} 